
import Koa from "koa";
import cors from "koa2-cors";
import koaJwt from "koa-jwt";
import koaBody from "koa-body";
import logger from "koa-logger";
import sysConf from "./confg/sys.conf";
import { init as initDB } from "./model";
import router from './route';
import intercept from "./middleware/intercept";

const app = new Koa();
app
  .use(cors({ origin: () => '*' }))
  .use(logger())
  .use(koaBody({
    multipart: true, // 启用文件上传支持
    formidable: {
      maxFileSize: 200 * 1024 * 1024, // 设置文件上传的最大限制，单位为字节（这里是 200MB）
    },
  }))
  .use(intercept())
  .use(router.routes())
  .use(router.allowedMethods());
async function bootstrap() {
  await initDB();
  app.listen(3000, () => {
    console.log('启动成功', 3000);
  });
}
bootstrap();
